﻿
using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    public partial class Category : BYFW.BOL.BaseEntity
    {
        public Category()
        {
            m_tableName = "t_category";
            m_hasName = true;
            m_hasComment = true;
            m_tblCacheManager.IsEnable = true;
            m_objCacheManager.Size = 1000;
        }

        protected DocType m_docType = DocType.法律法规;

        /// <summary>
        /// 文档类别
        /// </summary>
        public DocType DocType
        {
            get { return m_docType; }
            set { m_docType = value; }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("docType", (int)m_docType);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_docType = (DocType)this.GetIntValue(record, "docType");
            return true;
        }

        public DataTable GetRecordsByDocType(DocType docType)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("docType"), DB.GetVal((int)docType));
            return this.GetRecords(cond);
        }

        public List<Category> GetAllCategories()
        {
            return GetSpecialList<Category>(null, "");
        }
    }
}
